package reverselist;

/**
 * 翻转链表测试
 *
 * @author chenkuan
 * @since 2021/12/8 008 14:57
 */
public class Test {

    public static void main(String[] args) {
        ListNode<String> node1 = new ListNode<>("1");
        ListNode<String> node2 = new ListNode<>("2");
        ListNode<String> node3 = new ListNode<>("3");
        ListNode<String> node4 = new ListNode<>("4");
        ListNode<String> node5 = new ListNode<>("5");
        node1.next = node2;
        node2.pre = node1;
        node2.next = node3;
        node3.pre = node2;
        node3.next = node4;
        node4.pre = node3;
        node4.next = node5;
        node5.pre = node4;

        ListNode node = node1;
        while (node != null) {
            System.out.println(node.t);
            node = node.next;
        }

        System.out.println("---翻转链表---");

        node = new ReverseList().reverse(node1);
        while (node != null) {
            System.out.println(node.t);
            node = node.next;
        }
    }
}
